package handling.mina;

import handling.MapleServerHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.timeout.IdleStateHandler;

public class ServerInitializer extends ChannelInitializer<SocketChannel> {
    private int world;
    private int channels;

    public ServerInitializer(int world, int channels) {
        this.world = world;
        this.channels = channels;
    }

    @Override
    protected void initChannel(SocketChannel channel) throws Exception {
        ChannelPipeline pipe = channel.pipeline();
        pipe.addLast(new IdleStateHandler(90, 90, 0));
        pipe.addLast("decoder", new MaplePacketDecoder());
        pipe.addLast("encoder", new MaplePacketEncoder());
        pipe.addLast("handler", new MapleServerHandler(this.channels));
    }
}
